export default {
    post(url: any, data?: any) {
        return this.request(url, data, 'POST')
    },
    get(url: any, data?: any) {
        return this.request(url, data, 'GET')
    },
    request(url: any, data?: any, method ? : any) {
        return new Promise((resolve, reject) => {
            uni.request({
                url: url,
                method: method || 'GET',
                data: data || {},
                header: { // 自定义请求头
                    'code': '8888888888888888',
                    'Accept': 'application/json',
                    'Content-Type': 'application/json'
                },
                timeout: 10000, // 超时设置
                responseType: 'json', // 响应的数据格式
                success: (res) => {
                    let ressultData: any = {
                        code: -2,
                        message: '网络错误'
                    }
                    if (res.statusCode == 200) {
                        ressultData = res.data
                    }
                    resolve(ressultData)
                },
                fail: (err) => {
                    console.log('err === ', err);
                }
            });
        })
    }
}